package com.demo.springcloud.controller;

import com.demo.springcloud.pojo.CommonResult;
import com.demo.springcloud.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenyuan
 * @date 2020/12/24 15:13
 */

@RestController
@Slf4j
public class StorageController {

	@Autowired
	private StorageService storageService;

	//扣减库存
	@RequestMapping("/storage/decrease")
	public CommonResult decrease(Long productId, Integer count) {
		int decrease = storageService.decrease(productId, count);
		log.info("------ storage-decrease-影响行数 ：" + decrease);
		return new CommonResult(200, "扣减库存成功！", decrease);
	}
}
